<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>分类管理</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="__PUBLIC__/Theme1/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__PUBLIC__/Theme1/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/Theme1/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="__PUBLIC__/Theme1/css/animate.min.css" rel="stylesheet">
    <link href="__PUBLIC__/Theme1/css/style.min.css?v=4.1.0" rel="stylesheet">

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加(修改)桌位
                        <small></small>
                    </h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="form_basic.html#">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                   <form method="post" action="__URL__/editTable" class="form-horizontal">
                        <input type="hidden" value="{$result.id}" name="id">
                        <input type="hidden" id="qcrode_url" name="qcrode" value="{$result.qrcode}">

                       <if condition="$storeId eq 0">
                           <div class="form-group">
                               <label class="col-sm-2 control-label">店铺名称</label>
                               <div class="col-sm-4">
                                   <select id="category2" class="form-control" required name="store_id">
                                       <option value="0" >请选择...</option>
                                       <volist name="store" id="vo">
                                           <option value="{$vo['store_id']}" <if condition="$result.store_id eq $vo['store_id']"> selected </if>>{$vo['store_name']}</option>
                                       </volist>
                                   </select>
                               </div>
                           </div>
                       </if>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">桌位号</label>
                            <div class="col-sm-10">
                                    <input type="number"
                                           class="form-control"
                                           name="table_id"
                                           id="table_id"
                                           placeholder="<if condition='$storeId eq 0'> 请先选择店铺，再填写桌号！！！<else /> 请填写桌号 </if>"
                                           value="{$result.table_id}"
                                           required onblur="chkvalue(this)">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">桌位最大人数</label>
                            <div class="col-sm-10">
                                <input type="tel" name="num" id="num" placeholder="桌位最大人数"
                                       value="{$result.num}" class="form-control" required>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">桌位型号</label>
                            <div class="col-sm-1">
                                <select class="form-control" required name="model">
                                    <option value="1">小桌</option>
                                    <option value="2">中桌</option>
                                    <option value="3">大桌</option>
                                </select>
                            </div>
                        </div>

                       <div class="form-group">
                           <label class="col-sm-2 control-label">二维码</label>
                           <div class="col-sm-1">
                               <img class="qrcode" src=""/>
                           </div>
                       </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="submit">保存</button>
                                <a class="btn btn-white" href="{:U('Admin/Table/index')}">返回</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="__PUBLIC__/Theme1/js/jquery.min.js?v=2.1.4"></script>
<script src="__PUBLIC__/Theme1/js/bootstrap.min.js?v=3.3.6"></script>
<script src="__PUBLIC__/Theme1/js/content.min.js?v=1.0.0"></script>
<script src="__PUBLIC__/Theme1/js/plugins/iCheck/icheck.min.js"></script>
<script>
    $(function () {
        showQrcode();
    })
    //查看时 展示的二维码
    function showQrcode(){
        var table_id = $("#table_id").val();//桌号
        var store_id = $("#category2").val();//店铺ID
        if(table_id && store_id != 0){
            // alert(store_id);
            var qrcode_url = "http://mytest.bndvip.com/index.php?m=Admin&c=Table&a=qrcode&table_id="+ table_id +"&store_id=" + store_id;
            $('.qrcode').attr('src', qrcode_url);
        }
    }

    $(document).ready(function () {
        $(".i-checks").iCheck({checkboxClass: "icheckbox_square-green", radioClass: "iradio_square-green",   })
    });

    //修改和添加 桌号改变时 展示的二维码
    function chkvalue(txt) {
        var table_id = txt.value;
        if ({$storeId} == 0) {
            var obj = document.getElementById("category2");
            var index = obj.selectedIndex;
            var store_id = obj.options[index].value; //获店铺ID
        } else {
            var store_id = {$storeId};
        }

        var qrcode_url = "http://mytest.bndvip.com/index.php?m=Admin&c=Table&a=qrcode&table_id="+ table_id +"&store_id=" + store_id;
        $('.qrcode').attr('src', qrcode_url);
    }
</script>
</body>
</html>